package com.itheima.Jiuye16;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo03 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        Class<?> aClass = Class.forName("com.itheima.Jiuye16.Student2");  //获取Class对象
        //获取到里面的getmax方法对象
        Method method = aClass.getDeclaredMethod("getmax", String.class, int.class, String.class);
        method.setAccessible(true);   //去除私有化方法的权限
        Object o = aClass.newInstance();//用反射创建一个对象
        Object invoke = method.invoke(o,"张三",23,"中性");//调用Invoke方法运行方法，参数为：调用者，方法对应的参数
        System.out.println(invoke);
    }
}
